/**
 * Copyright(c) 2014 Xunton Solutions
 *
 * History:
 *   15-12-14 下午5:33 Created by dwzhang
 */
package com.jade.bss.ec.ware;

import javax.persistence.*;

/**
 * 商品规格。一个商品根据商品规格来对应多个商品SKU。
 *
 * @author <a href="mailto:dwzhang@xunton.com">dwzhang</a> 
 * @version 1.0 15-12-14 下午5:33
 */
@Entity
@Table (name = "BSS_EC_WARE_SPEC")
public class WareSpec
{
    public static final int TYPE_COLOR = 1;
    public static final int TYPE_SIZE = 2;
    public static final int TYPE_OTHER = 9;
    //商品规格标识
    @Id
    @GeneratedValue (generator = "BSS_SEQ_EC_WARE_SPEC")
    @SequenceGenerator (name = "BSS_SEQ_EC_WARE_SPEC", sequenceName = "BSS_SEQ_EC_WARE_SPEC")
    private long id;
    //所有者类型，不同的所有者可以定义自身的商品规格
    @Column (name = "owner_type", length = 32, nullable = false, updatable = false)
    private String ownerType;
    //所有者
    @Column (name = "owner_id", length = 64, nullable = false, updatable = false)
    private String ownerId;
    //商品所属分类
    @Column (name = "cid", nullable = false, updatable = false)
    private long cid;
    //为空表示该规格定义在分类上，否则为商品自定义的规格。一般颜色或者尺寸的规格由分类统一定义好
    //如果一个商品自定义了一个类型的规格，那么该类型的规格将不再使用在分类上的规格。
    @Column (name = "ware_id", updatable = false)
    private long wareId;
    //颜色/尺码/自定义规格
    @Column (name = "type", updatable = false)
    private int type = TYPE_COLOR;
    //规格对应的具体值，例如红色、绿色、M、L等。
    @Column (name = "value", length = 128, nullable = false)
    private String value;
    //排序码，越小越好
    @Column (name = "sort_code")
    private int sortCode;

    public long getId()
    {
        return id;
    }

    public void setId(long id)
    {
        this.id = id;
    }

    public String getOwnerType()
    {
        return ownerType;
    }

    public void setOwnerType(String ownerType)
    {
        this.ownerType = ownerType;
    }

    public String getOwnerId()
    {
        return ownerId;
    }

    public void setOwnerId(String ownerId)
    {
        this.ownerId = ownerId;
    }

    public long getCid()
    {
        return cid;
    }

    public void setCid(long cid)
    {
        this.cid = cid;
    }

    public long getWareId()
    {
        return wareId;
    }

    public void setWareId(long wareId)
    {
        this.wareId = wareId;
    }

    public int getType()
    {
        return type;
    }

    public void setType(int type)
    {
        this.type = type;
    }

    public String getValue()
    {
        return value;
    }

    public void setValue(String value)
    {
        this.value = value;
    }

    public int getSortCode()
    {
        return sortCode;
    }

    public void setSortCode(int sortCode)
    {
        this.sortCode = sortCode;
    }
}
